home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1995-02-09 | 9.3 KB | 238 lines |
- Module DatePick
- -----------------------------------------------------------------------
- DatePick Handling Routines
- -----------------------------------------------------------------------
- Public Methods Supported:
- shell_DatePick_Init Initialises module
- shell_DatePickerOpen Opens the DatePick DBox
- shell_AttachPopupDatePicker Attaches the DatePicker to a window/icon
- Private Methods Supported:
- DatePicker_PreOpen
- DatePicker_Selection
- _DatePicker_BumpHandler
- _DatePicker_BumpHandler2
- _DatePicker_DecodeDate
- _DatePicker_Click
- Message Strings required by module
- monthstr
- daystr
- today
- "*|Start FN_shell_DatePick_Init
- _shell_DatePickInit
- Define Constants
- EDATEPICK_TODAYICON% = 0 :
- Default action icon
- !TDATEPICK_FIRSTICON% = 11 :
- First icon that holds a day number
- "TDATEPICK_LASTICON% = 53 :
- Last icon that holds a day number
- #SDATEPICK_MONTHICON% = 1 :
- Icon handle of month display icon
- $RDATEPICK_MONTHINC% = 3 :
- Icon handle month increment icon
- %RDATEPICK_MONTHDEC% = 4 :
- Icon handle month decrement icon
- &PDATEPICK_YEARICON% = 2 :
- Icon handle year display icon
- 'QDATEPICK_YEARINC% = 55 :
- Icon handle year increment icon
- (QDATEPICK_YEARDEC% = 54 :
- Icon handle year decrement icon
- )PDATEPICK_FIRSTWEEKDAYICON% = 5 :
- Icon handle first weekday icon
- +EDATEPICK_ESG% = 1 :
- ESG of day nr icons
- ,GDATEPICK_SEP$ = "." :
- Date seperater string
- -EDATEPICK_WINDOWNAME$ = "datepicker" :
- Template identifier
- Define variables
- 0=G_DatePick_DBoxHandle% = -1 :
- DBox window handle
- 1HG_DatePick_NextIcon% = -1 :
- Next icon that needs updating
- 2CG_DatePick_DBox_Updated% =
- TRUE when DBox is up-to-date
- 3FG_DatePick_DBox_Created% =
- TRUE when DBox has been created
- 4_G_DatePick_NotifyFN$ = "" :
- FN to call when selection is made in datepicker dbox
- 5SG_DatePick_WindowHandle% = -1 :
- Handle of window containing display icon
- 6XG_DatePick_DisplayIcon% = -1 :
- Handle of icon to display resulting selection
- 7#G_DatePick_CurrDay% = -1
- 8#G_DatePick_CurrMonth% = -1
- 9#G_DatePick_CurrYear% = -1
- =#*|extract FN_DatePicker_PreOpen
- >'*|extract FN_DatePicker_BumpHandler
- ?(*|extract FN_DatePicker_BumpHandler2
- @&*|extract FN_DatePicker_DecodeDate
- A!*|extract FN_DatePicker_Click
- B-*|extract PROCshell_AttachPopupDatePicker
- D *|Stop FN_shell_DatePickInit
- H$*|Start PROCshell_DatePickerOpen
- *|!PROCshell_DatePickerOpen
- K8*|!Opens the datepicker dbox and calls the specified
- L(*|!routine when a selection is made.
- shell_DatePickerOpen( window_handle%, display_icon%, menu_icon%, notify_FN$ )
- O-G_DatePick_WindowHandle% = window_handle%
- P,G_DatePick_DisplayIcon% = display_icon%
- Q)G_DatePick_NotifyFN$ = notify_FN$
- shell_OpenWindowDynamic( DATEPICK_WINDOWNAME$, "_DatePicker_PreOpen", "" )
- shell_WindowMoveToPopUpPos( window_handle%, menu_icon%,
- shell_GetDynamicWindowHandle )
- V#*|Stop PROCshell_DatePickerOpen
- Z!*|Start FN_DatePicker_PreOpen
- _DatePicker_PreOpen( window_handle% )
- loop%,monthstr$, daystr$
- _+G_DatePick_DBoxHandle% = window_handle%
- "XHourglass_On"
- Fill in weekday names..
- loop% = 0
- shell_IconPutData( G_DatePick_DBoxHandle%, DATEPICK_FIRSTWEEKDAYICON% + loop%,
- shell_CalendarWeekDayString( loop% + 1 ),
- loop%
- And 'Today' button..
- shell_IconPutData( G_DatePick_DBoxHandle%, DATEPICK_TODAYICON%,
- shell_MessageNoArgs( "today" ),
- shell_AttachClickSelect( G_DatePick_DBoxHandle%, -1, "_DatePicker_Click" )
- shell_AttachHelpTag( G_DatePick_DBoxHandle%, -1, "dpwin" )
- shell_CalendarGetTodaysDate( G_DatePick_CurrDay% , G_DatePick_CurrMonth% , G_DatePick_CurrYear% )
- shell_DatePickerCreateCalendar( G_DatePick_CurrDay%, G_DatePick_CurrMonth% , G_DatePick_CurrYear% )
- shell_AttachBumpHandler( G_DatePick_DBoxHandle%, DATEPICK_MONTHICON%, DATEPICK_MONTHINC%, DATEPICK_MONTHDEC%, -9999, 9999, 1,
- , "_DatePicker_BumpHandler" , "_DatePicker_DecodeDate" )
- shell_AttachBumpHandler( G_DatePick_DBoxHandle%, DATEPICK_YEARICON%, DATEPICK_YEARINC%, DATEPICK_YEARDEC%, -9999, 9999, 1,
- , "_DatePicker_BumpHandler2" , "" )
- "Hourglass_Off"
- x *|Stop FN_DatePicker_PreOpen
- |.*|Start PROCshell_DatePickerCreateCalendar
- shell_DatePickerCreateCalendar( day%, month%, year% )
- day_of_week%, month_str$, day_nr%, start_icon%, days_in_month%
- selected%
- "Hourglass_On"
- B days_in_month% =
- shell_CalendarDaysInMonth( month%, year% )
- A day_of_week% =
- shell_CalendarDayOfWeek( 1, month%, year% )
- 7 month_str$ =
- shell_CalendarMonthString( month% )
- shell_CloseWindow( G_DatePick_DBoxHandle% )
- shell_IconPutData( G_DatePick_DBoxHandle%, DATEPICK_YEARICON%,
- ( year% ),
- shell_IconPutData( G_DatePick_DBoxHandle%, DATEPICK_MONTHICON%, month_str$,
- 7 start_icon% = DATEPICK_FIRSTICON% + day_of_week%
- Make first and last rows non-responsive to mouse clicks..
- icon% = 1
- Z
- shell_IconSetButtonType( G_DatePick_DBoxHandle%, icon% + DATEPICK_FIRSTICON%, 0 )
- X
- shell_IconPutData( G_DatePick_DBoxHandle%, icon% + DATEPICK_FIRSTICON%, "",
- G
- shell_IconPutData( G_DatePick_DBoxHandle%, icon% + 39, "",
- I
- shell_IconSetButtonType( G_DatePick_DBoxHandle%, icon% + 39, 0 )
- I
- shell_IconSetButtonType( G_DatePick_DBoxHandle%, icon% + 46, 0 )
- G
- shell_IconPutData( G_DatePick_DBoxHandle%, icon% + 46, "",
- icon%
- Deselect any selected icons in the ESG
- T selected% =
- shell_IconRadioSelection( G_DatePick_DBoxHandle%, DATEPICK_ESG% )
- selected% >= 0
- shell_IconSet( G_DatePick_DBoxHandle%, selected%, 0 )
- day_nr% = 1
- days_in_month%
- `
- shell_IconPutData( G_DatePick_DBoxHandle%, start_icon% + day_nr% - 1,
- ( day_nr% ),
- X
- shell_IconSetButtonType( G_DatePick_DBoxHandle%, start_icon% + day_nr% - 1, 3 )
- i
- day_nr% = G_DatePick_CurrDay%
- month% = G_DatePick_CurrMonth%
- year% = G_DatePick_CurrYear%
- P
- shell_IconSet( G_DatePick_DBoxHandle%, start_icon% + day_nr% - 1, 1 )
-
- day_nr%
- shell_OpenWindow( G_DatePick_DBoxHandle%,
- "Hourglass_Off"
- -*|Stop PROCshell_DatePickerCreateCalendar
- %*|Start FN_DatePicker_BumpHandler
- _DatePicker_BumpHandler( month%, button% )
- year%
- Qyear% =
- shell_IconGetData( G_DatePick_DBoxHandle%, DATEPICK_YEARICON% ) )
- month% < 1
- year% -= 1
- month% = 12
- month% > 12
- year% += 1
- month% = 1
- shell_DatePickerCreateCalendar( 1, month%, year% )
- shell_CalendarMonthString( month% )
- $*|Stop FN_DatePicker_BumpHandler
- &*|Start FN_DatePicker_BumpHandler2
- _DatePicker_BumpHandler2( year%, button% )
- month%
- lmonth% =
- shell_CalendarMonthNumber(
- shell_IconGetData( G_DatePick_DBoxHandle%, DATEPICK_MONTHICON% ) )
- shell_DatePickerCreateCalendar( 1, month%, year% )
- ( year% )
- %*|Stop FN_DatePicker_BumpHandler2
- $*|Start FN_DatePicker_DecodeDate
- _DatePicker_DecodeDate( month$ )
- shell_CalendarMonthNumber( month$ )
- #*|Stop FN_DatePicker_DecodeDate
- *|Start FN_DatePicker_Click
- _DatePicker_Click( window_handle%, icon_handle% )
- _date$, day%, month%, year%, offset%
- icon_handle% > DATEPICK_FIRSTICON%
- icon_handle% < DATEPICK_LASTICON%
- f month% =
- shell_CalendarMonthNumber(
- shell_IconGetData( window_handle%, DATEPICK_MONTHICON% ) )
- ` _date$ =
- "0" +
- shell_IconGetData( window_handle%, icon_handle% ), DATEPICK_YEARICON% )
- H _date$ += DATEPICK_SEP$ +
- "0" +
- ( month% ), 2 ) + DATEPICK_SEP$
- O _date$ +=
- shell_IconGetData( window_handle%, DATEPICK_YEARICON% ), 2 )
- shell_CloseWindow( window_handle% )
- DatePicker_Selection( _date$ )
- icon_handle% = 0
- shell_CalendarGetTodaysDate( day% , month% , year% )
- 8 _date$ =
- "0" +
- ( day% ), 2 ) + DATEPICK_SEP$
- 8 _date$ +=
- "0" +
- ( month% ), 2 ) + DATEPICK_SEP$
- ! _date$ +=
- ( year% ), 2 )
- shell_CloseWindow( window_handle% )
- DatePicker_Selection( _date$ )
- *|Stop FN_DatePicker_Click
- $*|Start PROCDatePicker_Selection
- DatePicker_Selection( _date$ )
- void%
- G_DatePick_NotifyFN$ <> ""
- ; void% =
- ( "FN" + G_DatePick_NotifyFN$ + "(_date$)" )
- G_DatePick_DisplayIcon% >= 0
- Z
- shell_IconPutData( G_DatePick_WindowHandle%, G_DatePick_DisplayIcon%, _date$,
- #*|Stop PROCDatePicker_Selection
- +*|Start PROCshell_AttachPopupDatePicker
- shell_AttachPopupDatePicker( wh%, menuic%, dispic%, notify_fn$ )
- shell_WindowLoaded( DATEPICK_WINDOWNAME$ )
- shell_DoAttachPopupHandler( wh%, menuic%, dispic%, -1, notify_fn$, 2 )
- 99,
- shell_MessageOneArg( "SHELLMSG37", DATEPICK_WINDOWNAME$ )
- **|Stop PROCshell_AttachPopupDatePicker
-